import http from "@/utils/request";
import type {CourseSchedule,CourseScheduleQueryParams} from "./types";

/**
 * 获取可用教练列表
 *
 * @param startTime
 * @param endTime
 */
export const queryAvailableCoach = (startTime:string, endTime:string) =>{
  return http({
    url: "/api/v1/course-schedule/queryAvailableCoach",
    method: "get",
    params: {startTime: startTime,endTime:endTime},
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 获取可用场地列表
 *
 * @param startTime
 * @param endTime
 */
export const queryAvailableVenue = (startTime:string, endTime:string) =>{
  return http({
    url: "/api/v1/course-schedule/queryAvailableVenue",
    method: "get",
    params: {startTime: startTime,endTime:endTime},
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

export const saveCourseSchedule = (courseSchedule: CourseSchedule) =>{
  return http({
    url: "/api/v1/course-schedule/save",
    method: "post",
    data: courseSchedule,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

export const updateCourseSchedule = (courseSchedule: CourseSchedule) =>{
  return http({
    url: "/api/v1/course-schedule/update",
    method: "put",
    data: courseSchedule,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 获取表单详情
 *
 * @param courseId
 */
export const getCourseScheduleForm = (courseId: number) =>{
  return http({
    url: "/api/v1/course-schedule/getCourseScheduleForm",
    method: "get",
    params: {courseId: courseId},
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 根据主键获取
 *
 * @param id
 */
export const getCourseScheduleById = (id: number) =>{
  return http({
    url: "/api/v1/course-schedule/getCourseScheduleById",
    method: "get",
    params: {id: id},
    headers: {
      'Content-Type': 'application/json'
    }
  });
}


/**
 * 获取分页列表
 *
 * @param queryParams
 */
export const getCourseSchedulePage = (queryParams: CourseScheduleQueryParams) => {
  return http({
    url: "/api/v1/course-schedule/page",
    method: "get",
    params: queryParams,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 删除信息
 * @param id
 */
export const deleteCourseSchedule = (id: number) => {
  return http({
    url: "/api/v1/course-schedule/delete",
    method: "delete",
    data: id,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

